package com.imti.mall.product.service.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.imti.mall.model.pms.dto.PmsProductAttributeCategoryResult;
import com.imti.mall.model.pms.pojo.PmsProductAttribute;
import com.imti.mall.model.pms.pojo.PmsProductAttributeCategory;
import com.imti.mall.product.mapper.PmsProductAttributeCategoryMapper;
import com.imti.mall.product.mapper.PmsProductAttributeMapper;
import com.imti.mall.product.service.PmsProductAttributeCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class PmsProductAttributeCategoryServiceImpl extends ServiceImpl<PmsProductAttributeCategoryMapper, PmsProductAttributeCategory> implements PmsProductAttributeCategoryService {

    @Resource
    private PmsProductAttributeCategoryMapper pmsProductAttributeCategoryMapper;
    @Resource
    private PmsProductAttributeMapper pmsProductAttributeMapper;

    @Override
    public List<PmsProductAttributeCategoryResult> findProductAttributeCategoryAndProductAttribute() {
       List<PmsProductAttributeCategoryResult> ppacr= pmsProductAttributeCategoryMapper.findPmsProductAttributeCategory();
        for(PmsProductAttributeCategoryResult result:ppacr){
            Long productAttributeCategoryId=result.getId();
            result.setProductAttributeList(pmsProductAttributeMapper.findPmsProductAttribute(productAttributeCategoryId));
        }
        return  ppacr;
    }
}
